<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/view/include/css-include.jsp"%>
<%@ include file="/view/include/jsp-include.jsp"%>
<%@ include file="/view/include/jquery-include.jsp"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Shipper Stock List</title>

<script type="text/javascript">
	$().ready(function() { 
		view(1);   
		$("#onWrite").bind("click",function(){
            location="/shipperstockWrite.html";            
        });
	    /* 조회버튼 */
	    $("#btnSearch").bind("click",function(){       
	    	view(1);
	    });
	    
	});

	function view(page){
		$.post(
                '/getShipperstockView.json', {                      
                paging : page,//odrNo,
                listScale : "15",
                custCode : $("#custCode").val(),
                custName : $("#custName").val(),
                goodsCode : $("#goodsCode").val(),
                goodsName : $("#goodsName").val(),                
                unit : $("#unit").val(),
                boxQty : $("#boxQty").val(),
                hsCode : $("#hsCode").val(),
                shipperstockCode : $("#shipperstockCode").val(),   
                iniQty : $("#iniQty").val()
               },
            function(data) {
                //$("#shipperstockDetail").remove();
                //reSetValidete(); //벨류데이션 초기화
                searchDataMaping(data);    //DATA맵핑 
            });
	}
	
	/* searchData 맵핑 */
    function searchDataMaping(data){
    	   
    	var contents = "";
    	$("#shipperstockDetail tr").remove();
        $.each(data.resultList, function(index){  // List로 받아온값 (여러건)  
           contents += "<tr><td align='center'>"+this.custCode+"</td>"
               +"<td align='left' class='boSub'>"+this.custName+"</td>"           
        	   +"<td align='center'>"+this.goodsName+"</td>"
               +"<td align='left' class='boSub'>"+this.unit+"</td>"
               +"<td align='left' class='boSub'>"+this.boxQty+"</td>"
               +"<td align='left' class='boSub'>"+this.hsCode+"</td>"
               +"<td align='left' class='boSub'>"+this.shipperstockCode+"</td>"
               +"<td align='left' class='boSub'>"+this.iniQty+"</td>"
        	   +"<td align='center'><a href='javascript:onUpdate(\""+this.custCode+"\",\""+this.goodsCode+"\");'><img src='images/web/ic_up.gif' alt='Update' id='onUpdate'/></a></td>"
               +"</tr>";
        });
        
        var totalPage = Math.ceil(parseInt(data.customeCount)/parseInt(15));        
        $("#spanCount").empty().html("Total : "+data.customeCount);
        $("#pageCount").empty().html("Page : "+$("#pageNum").val()+" / "+totalPage+" 페이지");                    
        $("#page").empty().html(data.pageSplit);
        
        $("#shipperstockDetail").append(contents);  // 조회 값 뿌리기
        
    }
    
    function onUpdate(custCode, goodsCode){
    	location="/shipperstockUpdate.html?custCode="+custCode + "&goodsCode="+goodsCode;
    }

    function onDel(arg){
    	$.post(
                '/delShipperstock.json', {  
                custCode : arg
               },
            function(data) {
           	   if(data.result == true){
                   alert("Deleted.....!");
                   view($("#pageNum").val());    
           	   }else{
           		   alert("ERROR!");
           	   }  
            });
    }

    function ajaxPageSplit(num) {
    	$("#pageNum").val(num);
        view(num);
    }
</script>
</head>
<body>
<div class="wrap">
	<div class="pagetitle">
    	<h1>Shipper Stock</h1>
	</div>
    <div>
    	<table class="TableST">
            <tr>
            	<th>Shipper Stock</th>
                <td>
                	<input type="text" class="inST" name="custCode" id="custCode"/>
                </td>
                <th>Shipper Name</th>
                <td>
                	<input type="text" class="inST" name="custName" id="custName"/><input type="button" class="btncss" id="btnSearch" value="search"/>
                </td>
            </tr>
        </table>
        <br /><br />     
        <ul>
        	<li class="totaltext"><span id="spanCount">Total : 0</span></li>
            <li class="pagetext"><span id="pageCount">Page : 1&frasl;1</span></li>
            <li class="bolistW">
            	<table class="TableST4">         	
                	<tr>
                    	<th width="65px">Shipper Code</th>
                        <th width="65px">Shipper Name</th>
                        <th width="65px">Goods Code</th>   
                        <th width="65px">Goods Name</th>
                        <th width="65px">Unit</th>
                        <th width="65px">Box Qty</th>
                        <th width="65px">HS Code</th>
                        <th width="65px">Shipper Stock Code</th> 
                        <th width="65px">Initial Stock Qty</th>
                        <th width="20px">U</th>
                    </tr>
                    <span id="shipperstockDetail">
	                    <tr>
	                       <td colspan="10"></td>	
	                    </tr>
                    </span>                    
                </table>
            </li>
        </ul>
    </div>
    <!--<div class="padeNum">
    <a href="#"><img src="images/web/icon_navi_01.gif" /></a>1.2.3.4.5.6.7<a href="#"><img src="images/web/icon_navi_02.gif" /></a>
    </div>
    -->
    <div class="page_wrap">
        <div class="page" id="page" >
        </div>
    </div>
    <input type="hidden" name="pageNum" id="pageNum" value="1">
</div>
</body>
</html>